package com.ymatou.iapi.godproductsearch.service;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;
/**
*商品搜索Call
*FreeMaker Template自动生成代码
*/
public class searchCall extends YmatouBaseCall{
	private static String opurl ="/search";
	
	public searchCall() {
		super(EnvSetup.getSystemUrl("godproductsearch_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	 public String getSuccess()
		{
		  return getString("success");
		}
		
	 public String getErrorCode()
		{
		  return getString("errorCode");
		}
	 
		 public Integer getRecordCount() throws JSONException
		{
			 return new JSONObject(getString("data").toString()).getInt("recordCount");
		}
		
		
		public JSONArray getProductDtos() throws JSONException
		{
		  return new JSONObject(getString("data").toString()).getJSONArray("productDtos");
		}
}